package com.tg.app.activity.device.add;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.appbase.custom.BuildConfig;
import com.tg.app.R;
import com.base.BaseActivity;
import com.tg.app.report.DeviceAddReport;
import com.tg.app.report.DeviceAddReportBean;
import com.tange.base.toolkit.StatusNavUtils;


public class Add4gCarDeviceActivity extends BaseActivity implements  View.OnClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);//remove title bar  即隐藏标题栏
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        setContentView(R.layout.activity_add_4g_device);
        hideActionBar();
        initView();

        // 如果只有 快速添加 这个选项，那么直接进入 快速添加
        if (BuildConfig.device_4gCarCamera_addByFast && !BuildConfig.device_4gCarCamera_addByQrCode) {
            Intent toQr = new Intent(this, AddFragmentTabActivity.class);
            toQr.putExtra(AddFragmentTabActivity.EXT_DEVICE_ADD_TYPE, AddFragmentTabActivity.DEVICE_ADD_4G_CAR_SEARCH);
            startActivity(toQr);
            finish();
            return;
        }

        // 如果只有 扫码添加 这个选项，那么直接进入 扫码添加
        if (!BuildConfig.device_4gCarCamera_addByFast && BuildConfig.device_4gCarCamera_addByQrCode) {
            Intent toQr = new Intent(this, AddFragmentTabActivity.class);
            toQr.putExtra(AddFragmentTabActivity.EXT_DEVICE_ADD_TYPE, AddFragmentTabActivity.DEVICE_ADD_4G_CAR);
            startActivity(toQr);
            finish();
            return;
        }
    }

    @Override
    public boolean shouldSetStatusBarColor() {
        return true;
    }

    @Override
    protected void initView() {
        findViewById(R.id.ap_add_rel).setOnClickListener(this);
        findViewById(R.id.qrcode_add_rel).setOnClickListener(this);
        findViewById(R.id.back_toolbar).setOnClickListener(this);


        findViewById(R.id.ap_add_rel).setVisibility(BuildConfig.device_4gCarCamera_addByFast ? View.VISIBLE : View.GONE);
        findViewById(R.id.qrcode_add_rel).setVisibility(BuildConfig.device_4gCarCamera_addByQrCode ? View.VISIBLE : View.GONE);
    }
    @Override

    public void onClick(View v) {
        DeviceAddReportBean bean = DeviceAddReport.getInstance().getReportBean();
        int id = v.getId();
        if (id == R.id.ap_add_rel) {
            Intent toQr = new Intent(this, AddFragmentTabActivity.class);
            toQr.putExtra(AddFragmentTabActivity.EXT_DEVICE_ADD_TYPE, AddFragmentTabActivity.DEVICE_ADD_4G_CAR_SEARCH);
            startActivity(toQr);
        } else if (id == R.id.qrcode_add_rel) {
            Intent toLan = new Intent(this, AddFragmentTabActivity.class);
            toLan.putExtra(AddFragmentTabActivity.EXT_DEVICE_ADD_TYPE, AddFragmentTabActivity.DEVICE_ADD_4G_CAR);
            startActivity(toLan);
        } else if (id == R.id.back_toolbar) {
            this.finish();
        }
        if (bean!=null){
            DeviceAddReport.getInstance().setReportBean(bean);
        }
    }


}
